package com.jcl.recruit.resume.model;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

/**
 * @ClassName ResumeExternalMsg
 * @Description TODO
 * @Author yyliu
 * @Date 2018/10/15 13:59
 * @Version 1.0
 **/
public class ResumeExternalMsg {

    private Integer id;

    private Integer resumeId;

    private String  context;

    private String  externalId;

    private Integer category;

    private String  source;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getResumeId() {
        return resumeId;
    }

    public void setResumeId(Integer resumeId) {
        this.resumeId = resumeId;
    }

    public String getContext() {
        return context;
    }

    public void setContext(String context) {
        this.context = context;
    }

    public String getExternalId() {
        return externalId;
    }

    public void setExternalId(String externalId) {
        this.externalId = externalId;
    }

    public Integer getCategory() {
        return category;
    }

    public void setCategory(Integer category) {
        this.category = category;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public static String decode(String content){
        String context = null;
        if(null != content){
            try {
                byte[] bytes = Base64.getDecoder().decode(content);
                context = new String(bytes, "utf-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        return context;
    }

    public static String encode(String content){
        if(null != content){
            try {
                String _context = Base64.getEncoder().encodeToString(content.getBytes("utf-8"));
               return _context;
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    public static void main(String[] args) {
        String ee = "eyJyZXN1bWVObyI6Ikc2VlZaWDB6TkJEMWgwZGtOUzBLTEEiLCJSZWZlcmVyIjoiaHR0cHM6Ly9yZDUuemhhb3Bpbi5jb20vcmVzdW1lL2RldGFpbD9rZXl3b3JkPWphdmEmcmVzdW1lTm89RzZWVlpYMHpOQkQxaDBka05TMEtMQV8xXzElM0IwOEIxMEVENDcyRUJFMkE4QzJGQUEyNTY2RjQ3RERERCUzQjE1Mzk4NTEwMTAxOTEmb3BlbkZyb209MSIsInJlc3VtZU5vX2tfdCI6Ikc2VlZaWDB6TkJEMWgwZGtOUzBLTEFfMV8xJTNCMDhCMTBFRDQ3MkVCRTJBOEMyRkFBMjU2NkY0N0REREQlM0IxNTM5ODUxMDEwMTkxIn0=";
        System.out.println(decode(ee));

    }
}
